$('#logout').on('click', function () {
  let isConfirm = confirm('您真的要退出吗？');
  if (isConfirm == true) {
    $.ajax({
      type: 'post',
      url: '/logout',
      success: function () {
        location.href = 'login.html';
      },
      error: function () {
        alert('退出失败');
      }
    })
  }
})

//处理日期格式
function dateFormat(date) {
  date = new Date(date);
  return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
}

// 查询用户的登录信息
$.ajax({
  type: 'get',
  url: '/users/' + userId,
  success: function (response) {
    $('.avatar').attr('src', response.avatar);
    $('.profile .name').html(response.nickName);
  }
})